package com.zhang.spark_1.test

import java.io.{InputStream, ObjectInputStream}
import java.net.{ServerSocket, Socket}

/**
 * @title:
 * @author: zhang
 * @date: 2021/12/5 10:47 
 */
object Executor1 {
  def main(args: Array[String]): Unit = {
    val server = new ServerSocket(9999)
    println("服务端启动，等待接收数据")
    //等待客户端连接
    val client: Socket = server.accept()

    val in: InputStream = client.getInputStream()

    val objectIn = new ObjectInputStream(in)
    val task: SubTask = objectIn.readObject().asInstanceOf[SubTask]

    println("计算节点[9999]计算结果为：" +  task.computer())
    objectIn.close()
    client.close()
    server.close()
  }
}
